<?php

namespace App\Http\Controllers\Personal;

use App\Model\Group_member;
use App\Model\Staff;
use App\Model\Store;
use App\Model\Users;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

class CommonController extends Controller
{
    //

	protected $Users;
	protected $Staff;
	protected $store_id;
	protected $Group_member;
	protected $store;
	public function __construct()
	{
		$userData=Auth::user();
		$this->Users=new Users();
		$this->Staff=new Staff();
		$this->store=new Store();
		$this->Group_member=new Group_member();
//		$staff_id=$this->Staff->where(['uid'=>$userData['id'],'type'=>1])->first()->id;
//		获取员工所属的店铺
//		$this->store_id=$this->Staff->staff_store($staff_id)->store->id;
//		获取用户所属的店铺
		$storeData=$this->store->department($userData->department);
		$this->store_id=$storeData['id'];
	}

	//	查询用户归属用户组
	public function belongsToGroup($department_id){
		$data=$this->Group_member->where(['department_id'=>$department_id])->first();
		$group_id=$data->group_id;
		return $group_id;
	}
}
